<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 字符串找不同 -->
    <script>
      var hammingWeight = function (n) {
        let ret = 0
        for (let i = 0; i < 32; i++) {
          if ((n & (1 << i)) !== 0) {
            //让1不断左移 判断该位是否为1
            ret++
          }
        }
        return ret
      }
      console.log(hammingWeight((t = 'abcde')))
    </script>
  </body>
</html>
